package com.zhangtai.modules.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangtai.modules.dto.EmployeeSecurityDto;
import com.zhangtai.modules.entity.employee.EmployeeSecurityEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-08-18 14:04:21
 */
@Mapper
public interface EmployeeSecurityDao extends BaseMapper<EmployeeSecurityEntity> {


    @Select("Update tb_employee_security set security_id = null where id =#{id}")
    void deleteSecurityById( Long id);

    @Select("Update tb_employee_security set funds_id = null where id =#{id}")
    void deleteFundsById(Long id);

    @Select("Update tb_employee_security set security_id = null where security_id =#{securityId}")
    void deleteSecurity( Long securityId);

    @Select("Update tb_employee_security set funds_id = null where funds_id =#{fundsId}")
    void deleteFunds( Long fundsId);

    @Select("<script>Select t1.*,t2.org_id,t2.employeestatus from tb_employee_security t1 " +
            "left join tb_employee_info t2 on  t1.oid = t2.oid " +
            "<where> t1.is_delete = 0 " +
            "<if test='fundsId!=null'> and funds_id =#{fundsId} </if>" +
            "<if test='securityId!=null'> and security_id =#{securityId} </if>" +
            "</where>" +
            "</script>")
    List<EmployeeSecurityDto> getUserSecurityList(@Param("fundsId") Long fundsId, @Param("securityId")Long securityId);
}
